﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NHibernate;
using NHibernate.Criterion;

using Revis.VClinicNet.Core.Domain.Repository;

namespace Revis.VClinicNet.Core.Domain.Persistence.Nh
{
    public class DoctorRepository : RepositoryBase<Doctor>, IDoctorRepository
    {
        public DoctorRepository(ISessionFactory factor) :
            base(factor)
        {
        }

        public IList<Doctor> FindAllActive()
        {
            IList<Doctor> doctors = Session.CreateCriteria<Doctor>("d")
                .Add(Expression.Eq("d.IsActive", true))
                .List<Doctor>();
            return doctors;
        }

        public IList<Doctor> FindAllWithWorkSchedules()
        {
            return Session.CreateCriteria<Doctor>("d")
                .SetFetchMode("d.WorkSchedule", FetchMode.Eager)
                .Add(Expression.Eq("d.IsActive", true))
                .List<Doctor>();
        }
    }
}
